{template header}
<script type="text/javascript" src="js/function.js"></script>
<script type="text/javascript">
var g_is_ok_username=1, g_is_ok_passwd=1, g_is_ok_email=1, g_is_ok_code=1;
var g_submited = false;
function check_username(){
	$('#checkusername').fadeOut();
	var result=false;
	var username=$.trim($('#username').val());
	var length=bytes(username);
	if(length==0){
		g_is_ok_username=0;
		$('#checkusername').html('{lang loginTip1}').fadeIn();
		divDance('checkusername');
	}else if( length <{$minlength} || length >{$maxlength}){
		$('#checkusername').html('{$loginTip2}').fadeIn();
		divDance('checkusername');
		g_is_ok_username=0;
	}else{
		jQuery.ajax({
			url: "index.php?user-checkusername",
			cache: false,
			dataType: "xml",
			type:"post",
			//async:false, 
			data: { username: username ,type:2 },
			success: function(xml){
				var	message=xml.lastChild.firstChild.nodeValue;
				if(message!='OK'){
					$('#checkusername').html(message).fadeIn();
					divDance('checkusername');
					g_is_ok_username=0;
				}else{
					$('#checkusername').html("<font color='green'>OK</font>").fadeIn();
					result=true;
					g_is_ok_username=1;
				}
			}
		});
	}
	return result;
}

function check_passwd(){
	$('#checkpasswd').fadeOut();
	var result=false;
	var passwd=$('#password').val();
	if( bytes(passwd) <1|| bytes(passwd)>32){
		$('#checkpasswd').html('{lang editPassTip1}').fadeIn();
		divDance('checkpasswd');
		g_is_ok_passwd=0;
	}else{
		$('#checkpasswd').html("<font color='green'>OK</font>").fadeIn();
		result=true;
		g_is_ok_passwd=1;
	}
	return result;
}

function check_repasswd(){
	$('#checkrepasswd').fadeOut();
	var result=false;
	var repassword=$('#repassword').val();
	if( bytes(repassword) <1|| bytes(repassword)>32){
		$('#checkrepasswd').html('{lang editPassTip1}').fadeIn();
		divDance('checkrepasswd');
		g_is_ok_passwd=0;
	}else{
		if($('#password').val()==$('#repassword').val()){
			$('#checkrepasswd').html("<font color='green'>OK</font>").fadeIn();
			result=true;
			g_is_ok_passwd=1;
		}else{
			$('#checkrepasswd').html('{lang editPassTip3}').fadeIn();
			divDance('checkrepasswd');
			g_is_ok_passwd=0;
		}
	}
	return result;
}

function check_email(email){
	$('#checkemail').fadeOut();
	var result=false;
	var email=$.trim($('#email').val());
	if (email=="" || !email.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
		g_is_ok_email=0;
		$('#checkemail').html('{lang getPassTip2}').fadeIn();
		divDance('checkemail');
	}else{
		jQuery.ajax({
			url: "index.php?user-checkemail",
			cache: false,
			dataType: "xml",
			//async:false, 
			type:"post",
			data: { email: email },
			success: function(xml){
				var	message=xml.lastChild.firstChild.nodeValue;
				if(message!='OK'){
					g_is_ok_email=0;
					$('#checkemail').html(message).fadeIn();
					divDance('checkemail');
				}else{
					g_is_ok_email=1;
					$('#checkemail').html("<font color='green'>OK</font>").fadeIn();
					result=true;
				}
			}
		});
	}
	return result;
}

function check_code(){
	$('#checkcode').fadeOut();
	var result=false;
	var code=$.trim($('#code').val());
	jQuery.ajax({
			url: "index.php?user-checkcode",
			cache: false,
			dataType: "xml",
			type:"post",
			//async:false, 
			data: { code: code },
			success: function(xml){
				var	message=xml.lastChild.firstChild.nodeValue;
				if(message=='OK'){
					g_is_ok_code=1;
					$('#checkcode').html("<font color='green'>OK</font>").fadeIn();
					result=true;
				}else{
					g_is_ok_code=0;
					$('#checkcode').html('{lang loginTip4}').fadeIn();
					divDance('checkcode');
				}
			}
	});
	return result;
}

function docheck(){
	//if( check_username()&&check_passwd()&&check_repasswd()&&check_email()){
	if(!g_submited && g_is_ok_username && g_is_ok_passwd && g_is_ok_email && g_is_ok_code){
		if(! $('#agree').attr('checked')){
			$('#chkagree').html('{lang registerTip1}').fadeIn();
			return false;
		}
		<!--{if $checkcode != 3 }-->
			//return check_code();
		<!--{/if}-->
		g_submited = true;
		return true;
	}else{
		return false;
	}
}

function updateverifycode() {
	var img = "index.php?user-code-"+Math.random();
	$('#verifycode').attr("src",img);
}

</script>
<style>
#advlist_0 {
    display:none;
}
</style>
<section class="wrap clearfix register">
	<div class="reg_main">
	<form id="registerform" method="post" action="{$formAction}" onsubmit="return docheck();">
		<h2 class="cblue">欢迎注册HDwiki账号</h2>
		<ul>
			<!--{if isset($forward) && $forward }-->
			<input name="forward"   type="hidden" value='{$forward}' />
			<!--{/if}-->
			<li class="inpt-name"><span>{lang userName}：</span><input name="username" tabindex="3"  id="username" type="text" maxlength="{$maxlength}" class="inp_txt" onblur="check_username()" placeholder="{lang userName}" /><label id="checkusername">{$loginTip2}</label></li>
			<li class="inpt-pwd"><span>{lang password}：</span><input name="password" tabindex="4" id="password" type="password" class="inp_txt" onblur="check_passwd()" maxlength="32" placeholder="{lang password}" /><label id="checkpasswd">*{lang editPassTip1}</label></li>
			<li class="inpt-pwd"><span>{lang renewPass}：</span><input name="repassword" tabindex="5" id="repassword" type="password" class="inp_txt" onblur="check_repasswd()" maxlength="32" placeholder="{lang renewPass}" /><label id="checkrepasswd"></label></li>
			<li class="inpt-eml"><span>E-mail：</span><input name="email" tabindex="6" id="email"  type="text" class="inp_txt" onblur="check_email()"  maxlength="50" placeholder="E-mail" /><label id="checkemail">*{lang registerTip3}</label></li>
			<!--{if $checkcode != "3"}-->
			<li class="yzm">
				<span>{lang verifyCode}</span>
				<input name="code" tabindex="7" type="text" class="inp_txt" id="code"  maxlength="4" onblur="check_code()" />
					<label class="yzm-img"><img id="verifycode" src="{url user-code}" onclick="updateverifycode();" /></label>&nbsp;
					<a class="clink" href="javascript:updateverifycode();">{lang codeNotClear}</a>
					<label id="checkcode">&nbsp;</label> 
			</li>
			<!--{/if}-->
			<li class="a-c"><input name="agree" id="agree" type="checkbox"  checked="checked" /><i class="checkbox"></i>{lang registerTip4}"<a href="{url doc-innerlink-{eval echo urlencode('{lang registerTip5}')}}" class="clink" target="_blank">{lang registerTip5}</a>" <label id="chkagree">&nbsp;</label></li>
			<!--{if (isset($error))}-->
			<li class="error">{$error}</li>
			<!--{/if}-->
			<li><input type="hidden" id="fromuid" name="fromuid" value="{$fromuid}"><input name="submit" tabindex="8" type="submit" value="{lang submit}" class="btn_inp blue" /></li>
			<li class="a-r gray9">{lang registerTip2} <a href="{url user-login}" target="_blank" class="clink">{lang login}></a></li>
		</ul>
	</form>
	</div>
	<figure class="regpic"><img src="style/default/hdwiki-regpic.png"></figure>
	<dl class="col-dl">
		<dt class="cblue f18">{lang registTip4}</dt>
		<dd class="gray9">{lang registTip1}</dd>
	</dl>
	<dl class="col-dl">
		<dt class="cblue f18">{lang registTip5}</dt>
		<dd class="gray9">{lang registTip2}</dd>
	</dl>
	<dl class="col-dl">
		<dt class="cblue f18">{lang registTip6}</dt>
		<dd class="gray9">{lang registTip3}</dd>
	</dl>
</section>
{template footer}